home *** CD-ROM | disk | FTP | other *** search
- '----------------------------------------------------------------------
- ' ***************
- ' * CGITEST.BAS *
- ' ***************
- '
- ' Test CGI back-end for NCSA httpd for Windows. Generates HTML report
- ' detailing the stuff it got from the server via the interface.
- '
- ' Requires procedures in CGI.BAS. Set the VB project options to use
- ' Sub Main as the startup form.
- '
- ' Author: Robert B. Denny <rdenny@netcom.com>
- ' June 7, 1994
- '----------------------------------------------------------------------
- Option Explicit
-
- '
- ' Do a database lookup on one of two fields in a book database
- '
- ' CGI.BAS contains the "Sub Main()" entry point. That code initializes
- ' the CGI environment, then calls CGI_Main(), here. At this point, the
- ' output file is open, the input file (if any) is NOT. Use the Send()
- ' function to isolate yourself from the output file number, and as
- ' a convenient shortcut.
- '
- ' NOTE: ALWAYS use FreeFile() to get file numbers if you need to open
- ' files in your code!
- Sub CGI_Main ()
- Dim Auth1First As String
- Dim Auth1Last As String
- Dim Auth2First As String
- Dim Auth2Last As String
- Dim ISBN As String
- Dim Copyright As Integer
- Dim Title As String
-
- Dim sel As String
- Dim buf As String
- Dim i As Integer
- Dim MyDB As Database, MySet As Dynaset
- Dim Query As String
-
- sel = LCase$(Mid$(CGI_LogicalPath, 2)) ' Skip leading "/"
- Select Case sel
- '
- ' Search for Title
- '
- Case "title"
- Query = "TITLE LIKE '*" & CGI_FormTuples(0).Value & "*' "
- StartDBReply
- If CGI_NumFormTuples < 1 Then
- Send ("<H2>No Query Entered</H2>")
- Else
-
- Set MyDB = OpenDatabase("C:\httpd\cgi-win\ibooks.MDB") ' Open a database.
- Set MySet = MyDB.CreateDynaset("Book Collection")
- MySet.FindFirst Query
- If MySet.NoMatch Then
- Send ("<H2>No Match in Database for Title " & CGI_FormTuples(0).Value & " </H2>")
- Else
- Auth1First = "" & MySet.Fields("Author1FirstName").Value
- Auth1Last = "" & MySet.Fields("Author1LastName").Value
- Auth2First = "" & MySet.Fields("Author2FirstName").Value
- Auth2Last = "" & MySet.Fields("Author2LastName").Value
- ISBN = MySet.Fields("ISBNNumber")
- Title = MySet.Fields("Title")
- Send ("<H2>Match(s) for Title " & CGI_FormTuples(0).Value & " </H2>")
- Send ("<P>Title: " & Title & "</P>")
- Send ("<P>Author: " & Auth1First & " " & Auth1Last & "</P>")
- If Auth2Last <> "" Then
- Send ("<P>Author: " & Auth2First & " " & Auth2Last & "</P>")
- End If
- Send ("<P>ISBN Number: " & ISBN & "</P>")
- While MySet.NoMatch = False
- MySet.FindNext Query
- If MySet.NoMatch = False Then
- Send ("<HR>")
- Auth1First = "" & MySet.Fields("Author1FirstName").Value
- Auth1Last = "" & MySet.Fields("Author1LastName").Value
- Auth2First = "" & MySet.Fields("Author2FirstName").Value
- Auth2Last = "" & MySet.Fields("Author2LastName").Value
- ISBN = MySet.Fields("ISBNNumber")
- Title = MySet.Fields("Title")
- Send ("<P>Title: " & Title & "</P>")
- Send ("<P>Author: " & Auth1First & " " & Auth1Last & "</P>")
- If Auth2Last <> "" Then
- Send ("<P>Author: " & Auth2First & " " & Auth2Last & "</P>")
- End If
- Send ("<P>ISBN Number: " & ISBN & "</P>")
- End If
- Wend
- End If
- MySet.Close
- MyDB.Close
- End If
-
- Case "author"
- Query = "Author1LastName LIKE '*" & CGI_FormTuples(0).Value & "*' OR Author2LastName LIKE '*" & CGI_FormTuples(0).Value & "*' "
- StartDBReply
- If CGI_NumFormTuples < 1 Then
- Send ("<H2>No Query Entered</H2>")
- Else
-
- Set MyDB = OpenDatabase("C:\httpd\cgi-win\ibooks.MDB") ' Open a database.
- Set MySet = MyDB.CreateDynaset("Book Collection")
- MySet.FindFirst Query
- If MySet.NoMatch Then
- Send ("<H2>No Match in Database for Author " & CGI_FormTuples(0).Value & " </H2>")
- Else
- Auth1First = "" & MySet.Fields("Author1FirstName").Value
- Auth1Last = "" & MySet.Fields("Author1LastName").Value
- Auth2First = "" & MySet.Fields("Author2FirstName").Value
- Auth2Last = "" & MySet.Fields("Author2LastName").Value
- ISBN = MySet.Fields("ISBNNumber")
- Title = MySet.Fields("Title")
- Send ("<H2>Match(s) for Author " & CGI_FormTuples(0).Value & " </H2>")
- Send ("<P>Title: " & Title & "</P>")
- Send ("<P>Author: " & Auth1First & " " & Auth1Last & "</P>")
- If Auth2Last <> "" Then
- Send ("<P>Author: " & Auth2First & " " & Auth2Last & "</P>")
- End If
- Send ("<P>ISBN Number: " & ISBN & "</P>")
- While MySet.NoMatch = False
- MySet.FindNext Query
- If MySet.NoMatch = False Then
- Send ("<HR>")
- Auth1First = "" & MySet.Fields("Author1FirstName").Value
- Auth1Last = "" & MySet.Fields("Author1LastName").Value
- Auth2First = "" & MySet.Fields("Author2FirstName").Value
- Auth2Last = "" & MySet.Fields("Author2LastName").Value
- ISBN = MySet.Fields("ISBNNumber")
- Title = MySet.Fields("Title")
- Send ("<P>Title: " & Title & "</P>")
- Send ("<P>Author: " & Auth1First & " " & Auth1Last & "</P>")
- If Auth2Last <> "" Then
- Send ("<P>Author: " & Auth2First & " " & Auth2Last & "</P>")
- End If
- Send ("<P>ISBN Number: " & ISBN & "</P>")
- End If
- Wend
- End If
- MySet.Close
- MyDB.Close
- End If
-
- End Select
-
- '
- ' Finish up with server admin's address. Return to complete HTTP.
- '
- Send ("<HR>")
- Send ("<A HREF=""mailto:" & CGI_ServerAdmin & """>")
- Send ("<address><" & CGI_ServerAdmin & "></address>")
- Send ("</A></BODY></HTML>")
-
- '****** RETURN, DON'T STOP! ******
- End Sub
-
- Sub StartDBReply ()
- Send ("Content-type: text/html")
- Send ("X-Script-name: Visual Basic Access CGI ")
- Send ("")
- Send ("<HTML><HEAD><TITLE>Database Lookup Results</TITLE></HEAD>")
- Send ("<BODY><H1>Database Lookup Results</H1>")
- Send ("<HR>")
-
- End Sub
-
- Sub StartDocument (sel As String)
- Send ("Content-type: text/html")
- Send ("X-Script-name: Visual Basic CGI Test 1.1")
- Send ("")
- Send ("<HTML><HEAD><TITLE>CGI Test Results</TITLE></HEAD>")
- Send ("<BODY><H1>CGI Test Results</H1>")
- Send ("Program version: 1.1 (12-Nov-94)<BR>")
- Send ("Server: <B>" & CGI_ServerSoftware & "</B><BR>")
- Send ("Selector: <B>" & sel & "</B><P>")
- Send ("<A HREF=""/cgitest.htm"">Return to usage document</A>")
- Send ("<HR>")
- End Sub
-
-